/*
 * WorkshopDesignApp.java
 */
package workshopdesign;

import java.util.Calendar;
import java.util.Date;
import java.util.EventObject;
import workshopdesign.UI.WorkshopDesignView;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
import workshopdesign.Control.SaveLoadController;

/**
 * The main class of the application.
 */
public class WorkshopDesignApp extends SingleFrameApplication {

    /**
     * At startup create and show the main frame of the application.
     */
    @Override
    protected void startup() {
        SaveLoadController.load();

        addExitListener(new ExitListener() {

            @Override
            public boolean canExit(EventObject event) {
                return true;
            }

            @Override
            public void willExit(EventObject event) {
                SaveLoadController.save();
            }
        });

        show(new WorkshopDesignView(this));
    }

    /**
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
     */
    @Override
    protected void configureWindow(java.awt.Window root) {
    }

    /**
     * A convenient static getter for the application instance.
     * @return the instance of WorkshopDesignApp
     */
    public static WorkshopDesignApp getApplication() {
        return Application.getInstance(WorkshopDesignApp.class);
    }

    /**
     * Main method launching the application.
     */
    public static void main(String[] args) {
        launch(WorkshopDesignApp.class, args);

//        Calendar cal = Calendar.getInstance();
//        current_time = cal.getTimeInMillis();
//
//        cal.setTime(borrowDate);
//        cal.add(cal.DAY_OF_YEAR, period);
//        long time_in_millis = cal.getTimeInMillis();
//        if (current_time > time_in_millis) {
//            //It is expired
//        }

    }
}
